import {createRouter,createWebHashHistory} from 'vue-router'

import Layout from '@/views/Layout/index.vue'
import Home from '@/views/Home/index.vue'


const router = createRouter({
    history:createWebHashHistory(),
    scrollBehavior(to, from, savedPosition) {
        // 始终滚动到顶部
        return { top: 0 }
    },
    routes:[
        {
            path:'/',
            component:Layout,
            children:[
                {path:"",component:Home},
                {path:"/category/:id",component:()=>import("@/views/Category/index.vue")},
                {path:"/category/sub/:id",component:()=>import("@/views/Category/sub.vue")}
            ]

        },
        {path:'/login',component:()=>import("@/views/Login/index.vue")},
        {path:'/demo',component:()=>import("@/views/demo/index.vue")}
    ]
})


export default router